package com.ms3ds.mineInfo.api.factory;

import com.ms3ds.common.core.domain.R;
import com.ms3ds.mineInfo.api.RemoteTeamService;
import com.ms3ds.mineInfo.api.domain.Team;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 矿山信息服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteTeamFallbackFactory implements FallbackFactory<RemoteTeamService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteTeamFallbackFactory.class);

    @Override
    public RemoteTeamService create(Throwable throwable)
    {
        log.error("矿山信息服务调用失败:{}", throwable.getMessage());
        return new RemoteTeamService()
        {
            @Override
            public R<List<Team>> getAllTeamByMineIdForRemote(Long mineId) {
                return R.fail("获取矿山id为" + mineId + "的生产队信息失败:" + throwable.getMessage());
            }

        };
    }
}
